package bman.game.battletank;

import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import bman.game.engine.Entity;

/**
 * This class is used to determine if a Tank can fire or not.
 * 
 * @author MrJacky
 *
 */
public class FireLimitter
{
	static Logger log = Logger.getLogger(FireLimitter.class.getName());
	private static Map properties = new HashMap();

	public static boolean canFire(Entity entity)
	{
		Long lastFire = (Long)properties.get("FIRE_"+entity.getID());
		if(lastFire != null)
		{
			long elapsed = System.currentTimeMillis() - lastFire.longValue();
			if(elapsed < 500)
			{
				log.fine("Entity ID: "+entity.getID()+". Fire suppressed.");
				return false;
			}
		}

		properties.put("FIRE_"+entity.getID(),new Long(System.currentTimeMillis()));
		return true;
	}

}
